package com.jsgt.greekfire.ui.mine.user.securityset

import android.text.TextUtils
import android.view.View
import com.fhx.core.base.BaseActivity
import com.fhx.core.goToActivity
import com.fhx.core.utils.ToastUtils
import com.jsgt.greekfire.R
import com.jsgt.greekfire.bean.UserBean
import com.jsgt.greekfire.ui.mine.user.changesecuritypwd.ChangeSecurityPwdActivity
import com.jsgt.greekfire.ui.mine.user.changetradingpwd.ChangeTradingPwdActivity
import com.jsgt.greekfire.ui.mine.user.securityset.bindmail.BindMailActivity
import com.jsgt.greekfire.ui.mine.user.securityset.bindphone.BindPhoneActivity
import com.jsgt.greekfire.ui.mine.user.securityset.verifyemail.VerifyEmailActivity
import com.jsgt.greekfire.ui.mine.user.securityset.verifyphone.VerifyPhoneActivity
import kotlinx.android.synthetic.main.activity_set_security.*

/**
 * 安全设置
 * author fhx
 * create time 2020/4/23 16:13
 **/
class SecuritySetActivity : BaseActivity() {
    override fun getLayoutId(): Int = R.layout.activity_set_security
    override fun onResume() {
        super.onResume()
//        if (TextUtils.isEmpty(UserBean.instance.email)) {
//            bind_mail_tv.text = getString(R.string.bind_mail)
//        } else {
//            bind_mail_tv.text = getString(R.string.change_mail)
//        }
        if (TextUtils.isEmpty(UserBean.instance.mobile)) {
            bind_phone_tv.text = getString(R.string.bind_phone)
            bind_phone_tv_hint.visibility = View.GONE
        } else {
            bind_phone_tv.text = UserBean.instance.mobile
            bind_phone_tv_hint.visibility = View.VISIBLE
            bind_phone_tv_hint.text = getString(R.string.change_phone)
        }
    }

    override fun main() {
        title = getString(R.string.security_set)

        bind_phone_ll.setOnClickListener {
            if (TextUtils.isEmpty(UserBean.instance.mobile)) {
                //绑定手机(原本有手机号就是修改)
                goToActivity<BindPhoneActivity>()
            } else {
                //验证手机
                goToActivity<VerifyPhoneActivity>()
            }
        }

        txvModifyPayPwd.setOnClickListener {
            if (TextUtils.isEmpty(UserBean.instance.mobile)) {
                ToastUtils.show(this, getString(R.string.bind_phone_first))
            } else {
                goToActivity<ChangeTradingPwdActivity>()
            }
        }

        txvModifyWalletPwd.setOnClickListener {
            goToActivity<ChangeSecurityPwdActivity>()
        }

//        bind_mail_tv.setOnClickListener {
//            if (TextUtils.isEmpty(UserBean.instance.email)) {
//                goToActivity<BindMailActivity>()
//            } else {
//                goToActivity<VerifyEmailActivity>()
//            }
//        }
    }
}